//
//  HTClassFeedbackVC.swift
//  QuitSmokingApp
//  
//  Created by wealon on 2024.
//  QuitSmokingApp.
//  
    

import UIKit

class HTClassFeedbackVC: HTClassViewController {
    lazy var var_contentTextView: UITextView = {
        let var_textView = UITextView()
        var_textView.textColor = UIColor("#999999")
        var_textView.font = .systemFont(ofSize: 16, weight: .semibold)
        var_textView.var_placeholder = "Please enter the content you would like to provide feedback on."
        var_textView.textContainerInset = .init(top: 10, left: 10, bottom: 10, right: 10)
        var_textView.layer.cornerRadius = 8.auto()
        var_textView.layer.masksToBounds = true
        
        var_textView.layer.borderWidth = 1
        var_textView.layer.borderColor = UIColor("#E0E0E0").cgColor
        var_textView.layer.shadowOffset = CGSize(width: 8, height: 8)
        var_textView.layer.shadowColor = UIColor("#E0E0E0").cgColor
        var_textView.layer.shadowRadius = 8.auto()
        return var_textView
    }()
    lazy var var_issueTextView: UITextView = {
        let var_textView = UITextView()
        var_textView.textColor = UIColor("#999999")
        var_textView.font = .systemFont(ofSize: 16, weight: .semibold)
        var_textView.var_placeholder = "Please enter your email address so that we can promptly provide you with feedback on the issue"
        var_textView.textContainerInset = .init(top: 10, left: 10, bottom: 10, right: 10)
        var_textView.layer.cornerRadius = 8.auto()
        var_textView.layer.masksToBounds = true
        
        var_textView.layer.borderWidth = 1
        var_textView.layer.borderColor = UIColor("#E0E0E0").cgColor
        var_textView.layer.shadowOffset = CGSize(width: 8, height: 8)
        var_textView.layer.shadowColor = UIColor("#E0E0E0").cgColor
        var_textView.layer.shadowRadius = 8.auto()
        return var_textView
    }()
    
    lazy var var_submit_button: UIButton = {
        let var_button = UIButton()
        var_button.titleLabel?.font = .systemFont(ofSize: 18.auto(), weight: .semibold)
        var_button.setTitle("Submit", for: .normal)
        var_button.setTitleColor(UIColor("#EB0505"), for: .normal)
        var_button.layer.cornerRadius = 8.auto()
        var_button.layer.borderWidth = 1
        var_button.layer.borderColor = UIColor("#EB0505").cgColor
        var_button.layer.masksToBounds = true
        return var_button
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        if let var_nav = self.navigationController as? HTClassNavigationController {
            var_nav.var_back.setImage(UIImage(named: "icon_black_back"), for: .normal)
        }
    
        title = "Feedback"
        self.var_bg_imageView.isHidden = true
        self.view.backgroundColor = .white
        // Do any additional setup after loading the view.
        
        
        let var_appearance = UINavigationBarAppearance()
        var_appearance.configureWithOpaqueBackground()
//        var_appearance.backgroundColor = HTClassTool.ht_getNavigationBack() // 设置背景颜色
        var_appearance.backgroundColor = .clear
        
        let var_navigationBarAppearance = UINavigationBarAppearance()
        var_navigationBarAppearance.configureWithOpaqueBackground()
        var_navigationBarAppearance.backgroundColor = .clear
        var_navigationBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.black, .font: UIFont.systemFont(ofSize: 20, weight: .bold) ]
        
        self.navigationController?.navigationBar.standardAppearance = var_appearance
        self.navigationController?.navigationBar.compactAppearance = var_navigationBarAppearance
        self.navigationController?.navigationBar.scrollEdgeAppearance = var_navigationBarAppearance
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.setNavigationBarHidden(false, animated: true)
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        if let var_nav = self.navigationController as? HTClassNavigationController {
            var_nav.var_back.setImage(UIImage(named: "icon_white_back"), for: .normal)
        }
    }
    
    override func ht_setUI() {
        super.ht_setUI()
        self.view.addSubview(var_contentTextView)
        self.view.addSubview(var_issueTextView)
        self.view.addSubview(var_submit_button)
        var_contentTextView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(14.auto())
            make.right.equalToSuperview().offset(-14.auto())
            make.top.equalToSuperview().offset(HTClassTool.STATIC_navigationBarTotalHeight + 20.auto())
            make.height.equalTo(184.auto())
        }
        
        var_issueTextView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(14.auto())
            make.right.equalToSuperview().offset(-14.auto())
            make.top.equalTo(var_contentTextView.snp.bottom).offset(20.auto())
            make.height.equalTo(110.auto())
        }
        
        var_submit_button.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(14.auto())
            make.right.equalToSuperview().offset(-14.auto())
            make.top.equalTo(var_issueTextView.snp.bottom).offset(70.auto())
            make.height.equalTo(44.auto())
        }
        var_submit_button.onTap { [weak self] in
            let var_content = self?.var_contentTextView.text ?? ""
            let var_inss = self?.var_issueTextView.text ?? ""
            if var_content.count == 0 {
                HTClassHudView().ht_showToastOnView(var_view: self!.view, var_title: "Please enter the feedback", var_completedBlock: nil).hide(animated: true, afterDelay: var_kHudHiddenTime)
                return
            }
            if var_inss.count == 0 {
                HTClassHudView().ht_showToastOnView(var_view: self!.view, var_title: "Please enter an email", var_completedBlock: nil).hide(animated: true, afterDelay: var_kHudHiddenTime)
                return
            }
            HTClassHudView().ht_showToastOnView(var_view: self!.view, var_title: "Feedback received successfully", var_completedBlock: nil).hide(animated: true, afterDelay: var_kHudHiddenTime)
            self?.navigationController?.popViewController(animated: true)
        }
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
